/* 
 * File:   miaux_test.cpp
 * Author: gcollier
 *
 * Created on December 4, 2008, 2:44 PM
 */

#include <stdlib.h>
#include <iostream>

#include <shader.h>

#include <miaux.h>

void print_color(const char *name, lofi::miaux::Color c)
{
	std::cout << "Value of " << name << " is: ";
	std::cout << "\tR: " << c.R() << ", G: " << c.G() << ", B: " << c.B() << ", A: " << c.A() << std::endl;
	std::cout << std::endl;
}

/*
 * 
 */
int main(int argc, char** argv)
{
	miColor test_mi_color;
	test_mi_color.r = 0.1;
	test_mi_color.g = 0.2;
	test_mi_color.b = 0.3;
	test_mi_color.a = 1.0;
	
	lofi::miaux::Color A(.5,.5,.5);
	lofi::miaux::Color B(.3,.3,.3);
	lofi::miaux::Color C(.8,.8,.8,.5);

	std::cout << "#########################\n";
	print_color("A       ", A);
	print_color("B       ", B);
	print_color("C       ", C);
	std::cout << "#########################\n";
	print_color("A+B     ", A+B);
	print_color("A+0.5f  ", A+0.5f);
	print_color("A+test_mi_color ", A+test_mi_color);
	std::cout << "#########################\n";
	print_color("A-B     ", A-B);
	print_color("A-0.5f  ", A-0.5f);
	print_color("A-test_mi_color ", A-test_mi_color);
	std::cout << "#########################\n";
	print_color("A*B     ", A*B);
	print_color("A*0.5f  ", A*0.5f);
	print_color("A*test_mi_color ", A*test_mi_color);
	std::cout << "#########################\n";
	print_color("A/B     ", A/B);
	print_color("A/0.5f  ", A/0.5f);
	print_color("A/test_mi_color ", A/test_mi_color);
	std::cout << "#########################\n";
	print_color("A%B     ", A%B);
	print_color("A%0.5f  ", A%0.5f);
	print_color("A%test_mi_color ", A%test_mi_color);
	std::cout << "#########################\n";
	lofi::miaux::Color BLENDED;
	BLENDED.blend(A,B,0.5);
	print_color("50% blend of A and B ", BLENDED);
	std::cout << "#########################\n";
	print_color("A       ", A);
	print_color("B       ", B);
	print_color("C       ", C);
	print_color("(A+B)*C ", (A+B)*C);
	std::cout << "#########################\n";


	std::cout << "Can we cast it to miColor? \t";
	try
	{
		float value = ((miColor)C).r;
		std::cout << "Yes!\n";
	} catch (...) {
		std::cout << "No!\n";
	}

	std::cout << "The luminance of A is " << (miScalar)A << std::endl;
	std::cout << "The luminance of A+test_mi_color is " << (miScalar)(A+test_mi_color) << std::endl;

	return (EXIT_SUCCESS);
}

